/*    */ package com.zimbra.cs.filter.jsieve;
/*    */ 
/*    */ import java.util.List;
/*    */ import org.apache.jsieve.Argument;
/*    */ import org.apache.jsieve.Arguments;
/*    */ import org.apache.jsieve.Block;
/*    */ import org.apache.jsieve.NumberArgument;
/*    */ import org.apache.jsieve.SieveContext;
/*    */ import org.apache.jsieve.StringListArgument;
/*    */ import org.apache.jsieve.commands.AbstractActionCommand;
/*    */ import org.apache.jsieve.exception.SieveException;
/*    */ import org.apache.jsieve.exception.SyntaxException;
/*    */ import org.apache.jsieve.mail.MailAdapter;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class Notify
/*    */   extends AbstractActionCommand
/*    */ {
/*    */   protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context)
/*    */     throws SieveException
/*    */   {
/* 38 */     List<Argument> args = arguments.getArgumentList();
/* 39 */     if (args.size() < 3) {
/* 40 */       throw new SyntaxException("Missing arguments");
/*    */     }
/* 42 */     Argument nextArg = (Argument)args.get(0);
/* 43 */     if (!(nextArg instanceof StringListArgument))
/* 44 */       throw new SyntaxException("Expected string");
/* 45 */     List<String> list = ((StringListArgument)nextArg).getList();
/* 46 */     if (list.size() != 1)
/* 47 */       throw new SyntaxException("Expected exactly one email address");
/* 48 */     String emailAddr = (String)list.get(0);
/*    */     
/* 50 */     nextArg = (Argument)args.get(1);
/* 51 */     if (!(nextArg instanceof StringListArgument))
/* 52 */       throw new SyntaxException("Expected string");
/* 53 */     list = ((StringListArgument)nextArg).getList();
/* 54 */     if (list.size() != 1)
/* 55 */       throw new SyntaxException("Expected exactly one subject");
/* 56 */     String subjectTemplate = (String)list.get(0);
/*    */     
/* 58 */     nextArg = (Argument)args.get(2);
/* 59 */     if (!(nextArg instanceof StringListArgument))
/* 60 */       throw new SyntaxException("Expected string");
/* 61 */     list = ((StringListArgument)nextArg).getList();
/* 62 */     if (list.size() != 1)
/* 63 */       throw new SyntaxException("Expected exactly one body");
/* 64 */     String bodyTemplate = (String)list.get(0);
/*    */     
/* 66 */     int maxBodyBytes = -1;
/* 67 */     List<String> origHeaders = null;
/* 68 */     if (args.size() == 4) {
/* 69 */       nextArg = (Argument)args.get(3);
/* 70 */       if ((nextArg instanceof NumberArgument)) {
/* 71 */         maxBodyBytes = ((NumberArgument)nextArg).getInteger().intValue();
/* 72 */       } else if ((nextArg instanceof StringListArgument)) {
/* 73 */         origHeaders = ((StringListArgument)nextArg).getList();
/*    */       } else {
/* 75 */         throw new SyntaxException("Invalid argument");
/*    */       }
/*    */     }
/* 78 */     if (args.size() == 5) {
/* 79 */       nextArg = (Argument)args.get(3);
/* 80 */       if (!(nextArg instanceof NumberArgument))
/* 81 */         throw new SyntaxException("Expected int");
/* 82 */       maxBodyBytes = ((NumberArgument)nextArg).getInteger().intValue();
/* 83 */       nextArg = (Argument)args.get(4);
/* 84 */       if (!(nextArg instanceof StringListArgument))
/* 85 */         throw new SyntaxException("Expected string list");
/* 86 */       origHeaders = ((StringListArgument)nextArg).getList();
/*    */     }
/*    */     
/* 89 */     mail.addAction(new ActionNotify(emailAddr, subjectTemplate, bodyTemplate, maxBodyBytes, origHeaders));
/* 90 */     return null;
/*    */   }
/*    */   
/*    */   protected void validateArguments(Arguments arguments, SieveContext context)
/*    */     throws SieveException
/*    */   {}
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/filter/jsieve/Notify.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */